package com.bwie.controller;

import com.bwie.pojo.TbPacketRecord;
import com.bwie.pojo.TbPolicy;
import com.bwie.service.TbPolicyService;
import com.bwie.utils.Result;
import com.bwie.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/packet/index")
public class IndexController {


    @Autowired
    TbPolicyService tbPolicyService;

    /**
     * @description 策略分页列表
     * @params [pageInfoVo]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/6/9 10:49
     */
    @PostMapping("/getPacketList")
    public Result getPacketList(@RequestBody PacketVo pageInfoVo){
        return tbPolicyService.getPacketList(pageInfoVo);
    }


    /**
     * @description 获取字典
     * @params [typeId]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/6/11 13:39
     */
    @PostMapping("/getDictList/{typeId}")
    public Result getDictList(@PathVariable(name = "typeId") Integer typeId){

        return tbPolicyService.getDictList(typeId);
    }

    /**
     * @description 导出
     * @params [userId]
     * @return void
     * @author 杰
     * @date 2025/6/11 13:39
     */
    @GetMapping("/getExcele/{userId}")
    public void  getExcele(@PathVariable(name = "userId") Integer userId){
        tbPolicyService.getExcele(userId);
    }


    /**
     * @description 添加
     * @params [tbPolicy]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/6/11 13:40
     */
    @PostMapping("/addPolicy")
    public Result addPolicy(@RequestBody @Validated TbPolicy tbPolicy){
        return tbPolicyService.addPolicy(tbPolicy);
    }



    @PostMapping("/grabRedPacket/{id}")
    public Result grabRedPacket(@PathVariable("id") Integer id){
        return tbPolicyService.grabRedPacket(id);
    }


    @PostMapping("/getRecordList")
    public Result getRecordList(@RequestBody RecordPageVo recordPageVo){
return tbPolicyService.getRecordList(recordPageVo);

    }

    @PostMapping("/getEndTime")
    public Result getEndTime(@RequestBody TimeInfoVo timeInfoVo){

        return tbPolicyService.getEndTime(timeInfoVo);
    }


    @PostMapping("/getRedRecordInfo")
    public Result getRedRecordInfo(@RequestBody RedInfoVo redInfoVo){

        return tbPolicyService.getRedRecordInfo(redInfoVo);
    }
}
